/*
 * EncoladorHelper.java
 *
 * Created on June 13, 2007, 9:39 AM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package com.computec.encolador.helper;


import com.computec.encolador.base.helper.BaseHelper;
import com.computec.encolador.dao.BaseEncoladorDAO;
import com.computec.encolador.exception.EncoladorException;
import com.src.computec.radar.base.dao.exception.DAOException;
import java.util.ArrayList;

/**
 *
 * @author fsanchez
 */
public class EncoladorHelper extends BaseHelper{
    
    /**
     * Creates a new instance of EncoladorHelper 
     */
    public EncoladorHelper() {
    }    
    
    
    public ArrayList getCategorias() throws EncoladorException{
	BaseEncoladorDAO dao = (BaseEncoladorDAO) this.getFactoryDAO().getEncoladorDAO();
	try {
	    return dao.getCategorias();
	}
	catch (DAOException e) {
	    throw new EncoladorException("EncoladorHelper:getCategorias: " + e.toString());
	} 
    }
    
     public ArrayList getImpresoras() throws EncoladorException{
	BaseEncoladorDAO dao = (BaseEncoladorDAO) this.getFactoryDAO().getEncoladorDAO();
	try {
	    return dao.getImpresoras();
	}
	catch (DAOException e) {
	    throw new EncoladorException("EncoladorHelper:getImpresoras: " + e.toString());
	} 
    }
     
    public ArrayList getJobs() throws EncoladorException{
	BaseEncoladorDAO dao = (BaseEncoladorDAO) this.getFactoryDAO().getEncoladorDAO();
	try {
	    return dao.getJobs();
	}
	catch (DAOException e) {
	    throw new EncoladorException("EncoladorHelper:getImpresoras: " + e.toString());
	} 
    }
    
    /*public boolean procesar() throws EncoladorException{
	BaseEncoladorDAO dao = (BaseEncoladorDAO) this.getFactoryDAO().getEncoladorDAO();
	WebServiceClient webServiceClient =WebServiceClient.getInstance();
	String command_="";
	 boolean serviceResult_=false;
	try{
	    serviceResult_=webServiceClient.invokeService(command_);	
	}catch(Exception e){
	    throw new EncoladorException("EncoladorHelper:procesar: " + e.toString());
	}
	return  serviceResult_;
    }*/
    
    public boolean procesar() throws EncoladorException {
	BaseEncoladorDAO dao = (BaseEncoladorDAO) this.getFactoryDAO().getEncoladorDAO();
	webserviceclient.WebServiceClient webServiceClient = webserviceclient.WebServiceClient.getInstance();
	String command_= "/usr/bin/konqueror";
	boolean serviceResult_=false;
	try {
	    serviceResult_= webServiceClient.runCommand(command_);
            System.out.println(serviceResult_);
	}
        catch(Exception e){
	    throw new EncoladorException("EncoladorHelper:procesar: " + e.toString());
	}
	return  serviceResult_;
    }
    
    public boolean[][] getMatrizJobXImpresora(int pCodigoJob,int pCodigoImpresora) throws EncoladorException{
	BaseEncoladorDAO dao = (BaseEncoladorDAO) this.getFactoryDAO().getEncoladorDAO();
	try {
	    return dao.getMatrizJobXImpresora(pCodigoJob, pCodigoImpresora);
	}
	catch (DAOException e) {
	    throw new EncoladorException("EncoladorHelper:getImpresoras: " + e.toString());
	}
    }   
}